<template>
	<view>
		<u-select
			v-model="value"
			:list="list"
			:title="title"
			:mode="selectedModel"
			@confirm="confirm"
			@input="close"
		></u-select>
	</view>
</template>

<script>
import config1 from '@/store/modules/config1.js';
import { getCareerList } from '@/api/user/user';
export default {
	props: {
		selectType: '',
	},
	data() {
		return {
			value: false,
			list: [],
			title:'',
			selectedModel:'single-column'
		};
	},

	methods: {
		confirm(e) {
			this.$emit('chooseValue', this.selectType, e);
		},
		close() {
			this.$emit('closeValue');
		}
	},
	watch: {
		selectType(val) {
			if (val) {
				this.value = true;
				if (val != 'job') {
					this.list = config1[val];
					switch(val){
						case 'marital_status':
									this.title = '婚姻状况';
						break;
						case 'education':
									this.title = '学历';
						break;
						case 'salary':
									this.title = '月收入';
						break;
						case 'selectShow':
									this.title = '单位性质';
						break;
						case 'housing':
									this.title = '住房';
						break;
						case 'height':
									this.title = '身高';
									this.list = config1.height()
						break;
						case 'sex':
									this.title = '性别';
						break;
					}
				} else {
					this.title = '职业',
					getCareerList().then(res => {
						this.list = res.data;
					});
				}
			}
		}
	}
};
</script>

<style></style>
